package com.wn32.main.demo2;

import java.io.*;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) {
        try {
            File fileIn = new File("D:\\io\\1.txt");
            File fileOut = new File("D:\\io\\2.txt");
            InputStreamReader inStream = new InputStreamReader(new FileInputStream(fileIn), "GBK");
            OutputStreamWriter writerStream = new OutputStreamWriter(new FileOutputStream(fileOut), "GBK");
            BufferedReader reader = new BufferedReader(inStream);
            BufferedWriter writer = new BufferedWriter(writerStream);
            ArrayList<String> list = new ArrayList<>();
            ArrayList<String> list1 = new ArrayList<>();
            String str;
            while ((str = reader.readLine()) != null) {
                list.add(str);
            }
            reader.close();
            System.out.println(list);
            for (String s : list) {
                String[] split = s.split("-");
                int age = Integer.parseInt(split[1]) + 1;
                String s1 = split[0] + "-" + age;
                list1.add(s1);
            }
//            System.out.println(list1);
            for (String s : list1) {
                writer.write(s);
                writer.newLine();
                writer.flush();
            }
            writer.close();
            System.out.println("读写成功");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
